<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算器</title>
</head>
<h1>切换大小写</h1>
<p>
    数据1：<input type="text" id="old">
</p>
<p>
    数据2：<input type="text" id="ol">
</p>
<p>
    <button onclick="up(1)">相加</button>
    <button onclick="up(2)">相减</button>
    <button onclick="up(3)">相乘</button>
    <button onclick="up(4)">相除</button>
</p>
<p>
    新数据：<input type="text" id="hh">
</p>
<body>
<script>
function up(n) {
    var text =document.querySelector("#old").value;
    var tex = document.querySelector("#ol").value;
    text = Number(text);
    tex = Number(tex);

    if (n == 1){
        document.querySelector("#hh").value = text + tex;
    }
    if (n == 2){
        document.querySelector("#hh").value = text - tex;
    }
    if (n == 3){
        document.querySelector("#hh").value = text *tex;
    }
    if (n == 4){
        document.querySelector("#hh").value = text /tex;
    }
}
</script>
</body>
</html>